/**
 * 统计页面业务统计门诊js
 * @author lh
 * 2016-01-15
 *
 */

//var province = $("#bc_province").combobox();
//$("#bc_city").combobox();
//$("#bc_district").combobox();
$('#bc_clinic_monthDate').val(new Date().Format('yyyy-MM'));
/**
 * 门诊数据表格属性配置
 */
//根据月份和区域查询住院信息
	function clinic_query(){
		debugger;
		$('#businessClinic_Grid').datagrid({
			url:'s/clinic/table',
			method:'post',
			queryParams:{
				month:$('#bc_clinic_monthDate').val(),
				province:$("#bc_province").combobox('getText')=='全国'? '': $("#bc_province").combobox('getText'),
				city:$("#bc_city").combobox('getText')== '全省' ? '': $("#bc_city").combobox('getText'),
				dist:$("#bc_district").combobox('getText') == '全市' ? '': $("#bc_district").combobox('getText')
			},
			loadFilter:orange.systemPage.selfLoadFilter
		});
	}
	$('#businessClinic_Grid').datagrid({ 
//		method:'get',
//		url:'s/clinic/table',
//		queryParams:{
//			month:$('#bc_clinic_monthDate').val(),
//			province:$("#bc_province").combobox('getText') == '全国' ? '': $("#bc_province").combobox('getText'),
//			city:$("#bc_city").combobox('getText') == '全省' ? '': $("#bc_city").combobox('getText'),
//			dist:$("#bc_district").combobox('getText') == '全市' ? '': $("#bc_district").combobox('getText')
//		},
	    singleSelect:true,
	    rownumbers:true,
	    columns:[[ 
	        {field:'guid',hidden:true},
	        {field:'orgName',title:'中医馆名称',width:'10%',sortable:true,halign:'center',formatter:bc_checkDetail},
	        {field:'receiver',title:'常规门诊人数',width:'11%',sortable:true,halign:'center'}, 
	        {field:'status',title:'远程门诊人数',width:'11%',sortable:true,halign:'center'},
	        {field:'messageType',title:'初诊人数',width:'11%',sortable:true,halign:'center'},
	        {field:'sendMode',title:'复诊人数',width:'11%',sortable:true,halign:'center'},
	        {field:'receivedAddress',title:'本地就诊',width:'11%',sortable:true,halign:'center'}, 
	        {field:'content',title:'外来就诊',width:'11%',sortable:true,halign:'center'}, 
	        {field:'content',title:'最多病种',width:'11%',sortable:true,halign:'center'}, 
	        {field:'content',title:'最多病种人数',width:'11%',sortable:true,halign:'center'}
	    ]],
	    pagination:true,
	    sortable:true,
	    sortName: 'type',
	    sortOrder: 'asc'
	});
	//grid link
	function bc_checkDetail(value, row, index){
		//debugger;
		if(value==null){
			return null;
		}else{
			return '<a href="#" onclick="tcmReloadOrCreate(\''+row.guid+'\',\''+row.orgName+'\')">'+value+'</a>';	
		}
	};
	
	//省级数据
	var pData=[{'id':1,'text':'全国'},{'id':2,'text':'北京市'},{'id':3,'text':'天津市'},{'id':4,'text':'河北省'}];
	$("#bc_province").combobox({
		data:pData,   
	    valueField:'id',   
	    textField:'text',
	    onLoadSuccess:function(data){
//	    	$("#bc_province").combobox('setValue',data[0].id);
	    },
	    onSelect:function(node){
	    	if(node.id==1){
//	    		$("#bc_city + .combo").hide();
//	    		$("#bc_district + .combo").hide();
//	    		$("#bc_city").combobox('setValue','00');
//	    		$("#bc_district").combobox('setValue','00');
	    	}else{
//	    		$('#show_bc_city')[0].style.display="inline-block";
	    		bc_city();//$("#bc_city + .combo").show();
	    	}
	    }
	});
	var cData=[{'id':1,'text':'全省'},{'id':2,'text':'西市'},{'id':3,'text':'东市'},{'id':4,'text':'北市'}];
	$("#bc_city").combobox({
//		data:cData,   
	    valueField:'id',   
	    textField:'text',
	    onLoadSuccess:function(data){
//	    	$("#bc_city").combobox('setValue',data[0].id);
	    },
	    onSelect:function(node){
	    	if(node.id==1){
//	    		$("#bc_district + .combo").hide();
//	    		$("#bc_district").combobox('setValue','00');
	    	}else{
//	    		$('#show_bc_district')[0].style.display="inline-block";
	    		bc_district();//$("#bc_district + .combo").show();
	    	}
	    } 
	});
	var tData=[{'id':1,'text':'全市'},{'id':2,'text':'西区'},{'id':3,'text':'东区'},{'id':4,'text':'北区'}];
	$("#bc_district").combobox({
//		data:tData,   
	    valueField:'id',   
	    textField:'text' ,
	    onLoadSuccess:function(data){
	    	//$("#bc_district").combobox('setValue',data[0].id);
	    }
	});
	function bc_city(){
		//市级数据
		$("#bc_city").combobox({data:cData});
	}
	
	function bc_district(){
		//区域数据
		$("#bc_district").combobox({data:tData});
	}